home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Sample Code / Music Architecture / Embedding Instruments / BigEasy / BigEasyControls.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-08  |  15.6 KB  |  824 lines  |  [TEXT/KAHL]

  1. /*
  2.     File:        BigEasyControls.c
  3.  
  4.     Copyright:    © 1990-1991, 1994 by Apple Computer, Inc., all rights reserved.
  5.  
  6.     This file is used in these builds: Warhol
  7.  
  8.     Change History (most recent first):
  9.  
  10.          <9>     6/10/94    dvb        nil control list behaves better.
  11.          <8>     4/13/92    dvb        Minor bugs (empty controllist, &c)
  12.          <7>      4/3/92    dvb        New calls.
  13.          <6>     5/28/91    JB        Added prototypes for BigEasy Proc Ptrs
  14.          <5>     5/22/91    PH        new style prototypes
  15.          <4>     4/25/91    JB        Changing to new THINK_C interface files
  16.          <3>     12/5/90    GW        Fix dispose easycontrol
  17.          <2>    11/17/90    dvb        Return unprocessed key-actions
  18.         <1>        11/17/90    dvb        New again after 1st CD!
  19.  
  20.     To Do:
  21. */
  22.  
  23. /*
  24.   * file: BigEasyControls.c
  25.   *
  26.   * started 25 May 1990 12:07:24 Friday at 310 Nobel
  27.   * 
  28.   * david van brink
  29.   *
  30.   */
  31.  
  32. /************************************
  33. * Inclusions
  34. ************************************/
  35.  
  36. #include <Memory.h>
  37. #include <QuickDraw.h>
  38. #include <Events.h>
  39.  
  40. #define privateEasyControls
  41. #include "BigEasy2.h"
  42. #include "BigEasyGrafish.h"
  43. #include "BigEasyTextish.h"
  44. #include "BigEasyControls.h"
  45.  
  46.  
  47. /************************************
  48. * Globals
  49. ************************************/
  50.  
  51. static short defaultColors[6] =
  52.     {
  53.     0,
  54.     PackColor555(46035,46035,46035),
  55.     PackColor555(25535,65535,25535),
  56.     PackColor555(24000,0,0),
  57.     0,
  58.     0
  59.     };
  60.  
  61. /************************************
  62. * Prototypes
  63. ************************************/
  64. static void SelectEasyControl(easyControl ech, easyControlList list);
  65. static void UnhighlightSelection(easyControlList list);
  66. static void WalkDrawEasyControlList(easyControlList list,long,long);
  67. static void WalkInvalEasyControlList(easyControlList list,long,long);
  68. static short GetControlNumber(easyControl ech);
  69.  
  70. /************************************
  71. * Routines
  72. ************************************/
  73. easyControl NewEasyControl(easyControlType *type,Rect *r, long variation, void *style,
  74.         long refcon,long id,long value,easyControlList list)
  75. /*
  76.   * Make a new handle for an easy control, and call the
  77.   * init routine for that control. Then, add it to the
  78.   * list passed in.
  79.   */
  80.     {
  81.     easyControl ech;
  82.     register easyControlPtr ec;
  83.     register easyControl w;
  84.     easyControlListPtr l;
  85.  
  86.     ech = (easyControl)NewHandle(sizeof(easyControlRecord));
  87.     FailNil(ech);
  88.  
  89.     HLock((Handle)ech);
  90.     ec = *ech;
  91.  
  92.     ec->next = nil;
  93.     ec->list = list;
  94.     l = *list;
  95.     w = l->firstControl;
  96.     if(!w)
  97.         {
  98.         ec->prev = nil;
  99.         l->firstControl = ech;
  100.         }
  101.     else
  102.         {
  103.         while((**w).next)
  104.             w = (**w).next;
  105.         (**w).next = ech;
  106.         ec->prev = w;
  107.         }
  108.  
  109.     ec->type = type;
  110.     ec->rect = *r;
  111.     ec->flags = easyControlActive;
  112.     ec->refcon = refcon;
  113.     ec->id = id;
  114.     ec->variation = variation;
  115.     ec->value = value;
  116.     ec->style = style;
  117.     ec->state = nil;
  118.  
  119.     ec->color[0] = defaultColors[0];
  120.     ec->color[1] = defaultColors[1];
  121.     ec->color[2] = defaultColors[2];
  122.     ec->color[3] = defaultColors[3];
  123.     ec->color[4] = defaultColors[4];
  124.     ec->color[5] = defaultColors[5];
  125.  
  126.     ec->actionProc = nil;
  127.     ec->initActionProc = nil;
  128.     ec->doneActionProc = nil;
  129.     ec->valueProc = nil;
  130. /*    ec->keyProc = nil; */
  131.  
  132.     ec->low = 0;
  133.     ec->high = 100;
  134.  
  135.     TextFont((**list).textFont);
  136.     TextFace((**list).textFace);
  137.     TextSize((**list).textSize);
  138.  
  139.  
  140.     (*type->newProc)(ec);
  141.  
  142.     HUnlock((Handle)ech);
  143.     return ech;
  144.     }
  145.  
  146. void DisposeEasyControl(easyControl ech, easyControlList list)
  147. /*
  148.   * remove a control from the list passed
  149.   */
  150.     {
  151.     register easyControl *w;
  152.     register easyControlPtr ec;
  153.     register easyControlListPtr l;
  154.     easyControl last;
  155.  
  156.     l = *list;
  157.     last = nil;
  158.     ec = *ech;
  159.     w = &l->firstControl;
  160.  
  161.     while(*w)
  162.         {
  163.         if(*w == ech)
  164.             {
  165.             *w = ec->next;
  166.             if (*w != nil)    /* Make sure its not nil - GW */
  167.                 (**(ec->next)).prev = last;
  168.             goto goHome;
  169.             }
  170.         else
  171.             {
  172.             last = *w;
  173.             w = &(***w).next;
  174.             }
  175.         }
  176. goHome:;
  177.     DisposHandle((Handle)ech);
  178.     }
  179.  
  180. void DisposeEasyControlList(easyControlList list)
  181.     {
  182.     register easyControl w,n;
  183.  
  184.     w = (**list).firstControl;
  185.     while(w)
  186.         {
  187.         n = (**w).next;
  188.         DisposeEasyControl(w,list);
  189.         w = n;
  190.         }
  191.     DisposHandle((Handle)list);
  192.     }
  193.  
  194. easyControlList NewEasyControlList(WindowPtr w,long refcon)
  195.     {
  196.     easyControlList listH;
  197.     easyControlListPtr list;
  198.  
  199.     listH = (easyControlList)NewHandle(sizeof(easyControlListRecord));
  200.     list = *listH;
  201.     list->firstControl = nil;
  202.     list->selectedControl = nil;
  203.     list->nextSelectedControl = nil;
  204.     list->ownerWindow = w;
  205.     list->refcon = refcon;
  206.     list->textFont = 3;    /* geneva */
  207.     list->textSize = 9;
  208.     list->textFace = bold;
  209.     list->nextIdle = 0;
  210.     list->ticksPerIdle = 30;
  211.  
  212.     return listH;
  213.     }
  214.  
  215. void KeyEasyControlList(easyControlList listH,short key,short mods,controlClickResult *ccr)
  216. /*
  217.   * Pass a keypress to the currently
  218.   * selected control. we swipe "tab"s
  219.   * to skip from control to control, and
  220.   * "esc" to say "no control selected".
  221.   */
  222.     {
  223.     register easyControl ech;
  224.     register easyControlPtr ec;
  225.     register easyControlListPtr list;
  226.     short listHState;
  227.     Boolean tookKey;
  228.  
  229.     listHState = HGetState((Handle)listH);
  230.     HLock((Handle)listH);
  231.     list = *listH;
  232.  
  233.     if(ccr)
  234.         {
  235.         ccr->whichControl = nil;
  236.         ccr->tracked = false;
  237.         ccr->value = 0;
  238.         ccr->refcon = 0;
  239.         ccr->id = 0;
  240.         }
  241.  
  242.     ech = list->selectedControl;
  243.     if(key == '\t')
  244.         {
  245.     nextEch:
  246.         if(ech)
  247.             {
  248.             if(mods & shiftKey)
  249.                 ech = (**ech).prev;
  250.             else
  251.                 ech =(**ech).next;
  252.             }
  253.         else
  254.             {
  255.             ech = list->firstControl;
  256.             if(mods & shiftKey && ech)
  257.                 while((**ech).next)
  258.                     ech = (**ech).next;
  259.             }
  260.         if(list->nextSelectedControl)
  261.             {
  262.             ech = list->nextSelectedControl;
  263.             list->nextSelectedControl = nil;
  264.             }
  265.  
  266.         if(ech && !(**ech).type->keyProc)        /* if its got no keyproc, it doesn't do keypresses */
  267.             goto nextEch;
  268.         SelectEasyControl(ech,listH);
  269.         }
  270.     else if(key == 27)            /* the escape key */
  271.         {
  272.         SelectEasyControl(nil,listH);
  273.         list->nextSelectedControl = ech;
  274.         }
  275.     else
  276.         {
  277.         if(ech)
  278.             {
  279.             HLock((Handle)ech);
  280.             ec = *ech;
  281.             (*ec->type->keyProc)(ec,key,mods,&tookKey);
  282.  
  283.             if(ccr)
  284.                 {
  285.                 ccr->whichControl = ech;
  286.                 ccr->tracked = tookKey;
  287.                 ccr->value = ec->value;
  288.                 ccr->refcon = ec->refcon;
  289.                 ccr->id = ec->id;
  290.                 }
  291.  
  292.             HUnlock((Handle)ech);
  293.  
  294.             UnhighlightSelection(listH);            /* and forestall the next idle-blink for a while */
  295.             }
  296.         }
  297.     HSetState((Handle)listH,listHState);
  298.     }
  299.  
  300. short GetControlNumber(register easyControl ech)
  301. /*
  302.   * return the position in whatever list owns this control
  303.   */
  304.     {
  305.     short n;
  306.  
  307.     n = 1;
  308.     while( (**ech).prev)
  309.         {
  310.         n++;
  311.         ech = (**ech).prev;
  312.         }
  313.     return n;
  314.     }
  315.  
  316.  
  317. void UnhighlightSelection(easyControlList listH)
  318. /*
  319.   * if there's a selected control,
  320.   * put it in the unhighlighted phase
  321.   */
  322.     {
  323.     register easyControl ech;
  324.     register easyControlPtr ec;
  325.     easyControlListPtr list;
  326.     short listHState;
  327.  
  328.     listHState = HGetState((Handle)listH);
  329.     HLock((Handle)listH);
  330.     list = *listH;
  331.  
  332.     ech = list->selectedControl;
  333.     if(ech)
  334.         {
  335.         list->nextIdle = TickCount()+list->ticksPerIdle;        /* reset the idling phase to normal    */
  336.         HLock((Handle)ech);
  337.         ec = *ech;
  338.         list->idleRef = 0;
  339.         SetPort((*ec->list)->ownerWindow);
  340.         (*ec->type->idleProc)(ec,&list->idleRef);
  341.         HUnlock((Handle)ech);
  342.         }
  343.     HSetState((Handle)listH,listHState);
  344.     }
  345.  
  346. easyControl ClickEasyControlList(easyControlList listH,Point p,
  347.         controlClickResult *ccr,short mods)
  348.     {
  349.     register easyControl w;
  350.     register easyControlPtr ec;
  351.     easyControlListPtr list;
  352.     short trackResult;
  353.     short whichControl;
  354.     short listHState;
  355.  
  356.     listHState = HGetState((Handle)listH);
  357.     HLock((Handle)listH);
  358.  
  359.     list = *listH;
  360.  
  361.     w = list->firstControl;
  362.     whichControl = 0;
  363.  
  364.     if(ccr)
  365.         {
  366.         ccr->whichControl = nil;
  367.         ccr->tracked = false;
  368.         ccr->value = 0;
  369.         ccr->refcon = 0;
  370.         ccr->id = 0;
  371.         }
  372.  
  373.     while(w)
  374.         {
  375.         whichControl++;
  376.         if(PtInRect(p,&(**w).rect) && (**w).type->trackProc)        /* in rect and mouse sensitive */
  377.             {
  378.             SelectEasyControl(nil,listH);
  379.             HLock((Handle)w);
  380.             ec = *w;
  381.             ec->flags |= easyControlTracking;
  382.             if(ec->type->keyProc)                            /* never select keyless control */
  383.                 list->nextSelectedControl = w;
  384.             trackResult = 0;
  385.             ec->flags |= easyControlSetValue;
  386.             (*ec->type->trackProc)(ec,p,&trackResult,mods);
  387.             if(trackResult && ec->valueProc)
  388.                 (*ec->valueProc)(w);
  389.             ec->flags &= ~easyControlSetValue;
  390.  
  391.             if(ccr)
  392.                 {
  393.                 ccr->whichControl = w;
  394.                 ccr->tracked = true;
  395.                 ccr->value = ec->value;
  396.                 ccr->refcon = ec->refcon;
  397.                 ccr->id = ec->id;
  398.                 }
  399.  
  400.             ec->flags &= ~easyControlTracking;
  401.             (*ec->type->drawValueProc)(ec);
  402.             HUnlock((Handle)w);
  403.             goto goHome;
  404.             }
  405.         else
  406.             w = (**w).next;
  407.         }
  408. goHome:;
  409.     HSetState((Handle)listH,listHState);
  410.     return w;
  411.     }
  412.  
  413. void DrawEasyControlList(register easyControlList list)
  414.     {
  415.     WalkDrawEasyControlList(list,~0,0);
  416.     }
  417.  
  418. void DeactivateEasyControlList(easyControlList list)
  419. /*
  420.   * A window should call this when it
  421.   * becomes un-frontmost
  422.   */
  423.     {
  424.     WalkDrawEasyControlList(list,~0,easyControlBack);
  425.     }
  426.  
  427. void ActivateEasyControlList(easyControlList list)
  428. /*
  429.   * A window should call this when it
  430.   * becomes frontmost
  431.   */
  432.     {
  433.     WalkInvalEasyControlList(list,~easyControlBack,0);
  434.     }
  435.  
  436.  
  437. void WalkDrawEasyControlList(easyControlList listH,long and,long or)
  438. /*
  439.   * The gut routine of Draw, Activate, and DeactivateEasyControlList
  440.   */
  441.     {
  442.     register easyControlPtr ec;
  443.     register easyControl w;
  444.     register easyControlListPtr list;
  445.     short listHState;
  446.     GrafPtr oldPort;
  447.  
  448.     if(!listH)
  449.         goto goHome;
  450.  
  451.     GetPort(&oldPort);
  452.  
  453.     listHState = HGetState((Handle)listH);
  454.     HLock((Handle)listH);
  455.  
  456.     list = *listH;
  457.  
  458.     SetPort(list->ownerWindow);
  459.     TextFont(list->textFont);
  460.     TextFace(list->textFace);
  461.     TextSize(list->textSize);
  462.     w = list->firstControl;
  463.     while (w)
  464.         {
  465.         HLock((Handle)w);
  466.         ec = *w;
  467.         ec->flags &= and;
  468.         ec->flags |= or;
  469.         (*ec->type->drawProc)(ec);
  470.         ValidRect(&ec->rect);
  471.         HUnlock((Handle)w);
  472.         w = ec->next;
  473.         }
  474.     HSetState((Handle)listH,listHState);
  475.  
  476.     SetPort(oldPort);
  477. goHome:;
  478.     }
  479.  
  480.  
  481. void WalkInvalEasyControlList(easyControlList listH,long and,long or)
  482. /*
  483.   * The gut routine of Draw, Activate, and DeactivateEasyControlList
  484.   */
  485.     {
  486.     register easyControlPtr ec;
  487.     register easyControl w;
  488.     register easyControlListPtr list;
  489.     short listHState;
  490.  
  491.     listHState = HGetState((Handle)listH);
  492.     HLock((Handle)listH);
  493.  
  494.     list = *listH;
  495.  
  496.     SetPort(list->ownerWindow);
  497.     w = list->firstControl;
  498.     while (w)
  499.         {
  500.         HLock((Handle)w);
  501.         ec = *w;
  502.         ec->flags &= and;
  503.         ec->flags |= or;
  504.         InvalRect(&ec->rect);
  505.         HUnlock((Handle)w);
  506.         w = ec->next;
  507.         }
  508.     HSetState((Handle)listH,listHState);
  509.     }
  510.  
  511.  
  512.  
  513. void IdleEasyControlList(register easyControlList listH)
  514.     {
  515.     register easyControl ech;
  516.     easyControlPtr ec;
  517.     register easyControlListPtr list;
  518.     long t;
  519.     short listHState;
  520.  
  521.     listHState = HGetState((Handle)listH);
  522.     HLock((Handle)listH);
  523.     list = *listH;
  524.  
  525.     ech = list->selectedControl;
  526.     if(ech)
  527.         {
  528.         t = TickCount();
  529.         if(t > list->nextIdle)
  530.             {
  531.             list->nextIdle = t+list->ticksPerIdle;
  532.             list->idleRef++;
  533.             HLock((Handle)ech);
  534.             ec = *ech;
  535.             SetPort((*ec->list)->ownerWindow);
  536.             (*ec->type->idleProc)(ec,&list->idleRef);
  537.             HUnlock((Handle)ech);
  538.             }
  539.         }
  540.     HSetState((Handle)listH,listHState);
  541.     }
  542.  
  543. void SetEasyControlValue(register easyControl ech,long v)
  544.     {
  545.     register easyControlPtr ec;
  546.     becSetValueProcPtr svp;
  547.  
  548.     HLock((Handle)ech);
  549.     ec = *ech;
  550.     SetPort((*ec->list)->ownerWindow);
  551.     svp = ec->type->setValueProc;
  552.     if(svp)
  553.         (*svp)(ec,v);
  554.     else
  555.         ec->value = v;
  556.     ec->flags |= easyControlSetValue;
  557.     (*ec->type->drawValueProc)(ec);
  558.     ec->flags &= ~easyControlSetValue;
  559.     HUnlock((Handle)ech);
  560.     }
  561.  
  562. long GetEasyControlValue(easyControl ech)
  563.     {
  564.     return (**ech).value;
  565.     }
  566.  
  567. long GetEasyControlRefcon(easyControl ech)
  568.     {
  569.     return (**ech).refcon;
  570.     }
  571.  
  572. long GetEasyControlID(easyControl ech)
  573.     {
  574.     return (**ech).id;
  575.     }
  576.  
  577.  
  578.  
  579. void SetEasyControlRange(easyControl ech,long l,long h)
  580.     {
  581.     register easyControlPtr ec;
  582.  
  583.     ec = *ech;
  584.     ec->low = l;
  585.     ec->high = h;
  586.     }
  587.  
  588. void SetEasyControlValueProc(easyControl ech,becValueProcPtr proc)
  589.     {
  590.     register easyControlPtr ec;
  591.  
  592.     ec = *ech;
  593.     ec->valueProc = proc;
  594.     }
  595.  
  596. void SetEasyControlActionProc(easyControl ech,becActionProcPtr proc)
  597.     {
  598.     register easyControlPtr ec;
  599.  
  600.     ec = *ech;
  601.     ec->actionProc = proc;
  602.     }
  603.  
  604. void SetEasyControlInitActionProc(easyControl ech,becInitActionProcPtr proc)
  605.     {
  606.     register easyControlPtr ec;
  607.  
  608.     ec = *ech;
  609.     ec->initActionProc = proc;
  610.     }
  611.  
  612. void SetEasyControlDoneActionProc(easyControl ech,becDoneActionProcPtr proc)
  613.     {
  614.     register easyControlPtr ec;
  615.  
  616.     ec = *ech;
  617.     ec->doneActionProc = proc;
  618.     }
  619.  
  620. void GetEasyControlColors(easyControl ech,register short *colors)
  621.     {
  622.     register short i;
  623.     register short *src;
  624.  
  625.     if(ech)
  626.         src = &(**ech).color[0];
  627.     else
  628.         src = &defaultColors[0];
  629.     for(i = 5; i>=0; i--)
  630.         *colors++ = *src++;
  631.     }
  632.  
  633. void SetEasyControlColors(easyControl ech,register short *colors)
  634.     {
  635.     register short i;
  636.     register short *dst;
  637.  
  638.     if(ech)
  639.         dst = &(**ech).color[0];
  640.     else
  641.         dst = &defaultColors[0];
  642.     for(i = 5; i>=0; i--)
  643.         *dst++ = *colors++;
  644.     }
  645.  
  646.  
  647. void SelectEasyControl(easyControl ech,easyControlList listH)
  648. /*
  649.   * Unselect the current one (if any)
  650.   * and start the new one blinking.
  651.   */
  652.     {
  653.     register easyControlListPtr list;
  654.     short listHState;
  655.  
  656.     listHState = HGetState((Handle)listH);
  657.     HLock((Handle)listH);
  658.     list = *listH;
  659.  
  660.     list->idleRef = 0;
  661.     UnhighlightSelection(listH);
  662.     list->selectedControl = ech;
  663.     list->nextIdle = 0;
  664.     IdleEasyControlList(listH);
  665.  
  666.     HSetState((Handle)listH,listHState);
  667.     }
  668.  
  669. void GetEasyControlRect(easyControl ech,Rect *r)
  670. /*
  671.   * Return the current bounds of the control
  672.   */
  673.     {
  674.     *r = (**ech).rect;
  675.     }
  676.  
  677. void SetEasyControlRect(easyControl ech,Rect *r)
  678. /*
  679.   * Move the control to the newly specified rectangle
  680.   */
  681.     {
  682.     register easyControlPtr ec;
  683.  
  684.     HLock((Handle)ech);
  685.     ec = *ech;
  686.     SetPort((*ec->list)->ownerWindow);
  687.     InvalRect(&ec->rect);
  688.     ec->rect = *r;
  689.     ec->flags |= easyControlMoved;
  690.     InvalRect(&ec->rect);
  691.     HUnlock((Handle)ech);
  692.     }
  693.  
  694. unsigned short Replicate555(register unsigned short x)
  695.     {
  696.     x &= 0x001F;
  697.     return (x<<11) | (x<<6) | (x<<1) | (x>>4);
  698.     }
  699.  
  700. void Color555(register short x,register RGBColor *c)
  701.     {
  702.     c->red = Replicate555(x>>10);
  703.     c->green = Replicate555(x>>5);
  704.     c->blue = Replicate555(x);
  705.     }
  706.  
  707. void Fore555(register short x)
  708.     {
  709.     RGBColor c;
  710.  
  711.     Color555(x,&c);
  712.     RGBForeColor(&c);
  713.     RGBBackColor(&c);
  714.     }
  715.  
  716. #define kGrade 24000
  717. static long PinAdd(long,long);
  718. static long PinAdd(register long a,register long b)
  719.     {
  720.     a+= b;
  721.     if(a > 65535)
  722.         a = 65535;
  723.     else if(a < 0)
  724.         a = 0;
  725.     return a;
  726.     }
  727.  
  728. void Fore555Light(register short x)
  729.     {
  730.     RGBColor c;
  731.  
  732.     Color555(x,&c);
  733.     c.red = PinAdd(c.red,kGrade);
  734.     c.green = PinAdd(c.green,kGrade);
  735.     c.blue = PinAdd(c.blue,kGrade);
  736. /*
  737.     c.green = (c.green + 65535L)>>1;
  738.     c.blue = (c.blue + 65535L)>>1;*/
  739.     RGBForeColor(&c);
  740.     }
  741.  
  742. void Fore555Dark(register short x)
  743.     {
  744.     RGBColor c;
  745.  
  746.     Color555(x,&c);
  747.     c.red = PinAdd(c.red,-kGrade);
  748.     c.green = PinAdd(c.green,-kGrade);
  749.     c.blue = PinAdd(c.blue,-kGrade);
  750. /*    c.red = c.red >> 1;
  751.     c.green = c.green >> 1;
  752.     c.blue = c.blue >> 1;*/
  753.     RGBForeColor(&c);
  754.     }
  755.  
  756. #define kCCEdge 10000
  757. void Fore555Contrast(register short x)
  758. /*
  759.   * Make a color that contrasts well with
  760.   * the passed color: invert if close to a
  761.   * side of the color cube, or shift by 32768
  762.   */
  763.     {
  764.     RGBColor c;
  765.  
  766.     Color555(x,&c);
  767.     if(c.red < kCCEdge || c.red > (65535-kCCEdge) ||
  768.             c.green < kCCEdge || c.green > (65535-kCCEdge) ||
  769.             c.blue < kCCEdge || c.blue > (65535-kCCEdge) )
  770.         {
  771.         c.red = ~c.red;
  772.         c.green = ~c.green;
  773.         c.blue = ~c.blue;
  774.         }
  775.     else
  776.         {
  777.         c.red += 32768;
  778.         c.green += 32768;
  779.         c.blue += 32768;
  780.         }
  781.     RGBForeColor(&c);
  782.     }
  783.  
  784. void RaisedRect(register Rect *r,register short x)
  785. /*
  786.   * Draw rectangle r with a 1 pixel highlight
  787.   * to raise it off the screen
  788.   */
  789.     {
  790.     Fore555(x);
  791.     if( ((r->right - r->left) <= 2) || ((r->bottom - r->top) <= 2) )
  792.         PaintRect(r);
  793.     else
  794.         {
  795.         PenSize(1,1);
  796.         PaintRect(r);
  797.         Fore555Light(x);
  798.         MoveTo(r->left,r->bottom-1);
  799.         LineTo(r->left,r->top);
  800.         LineTo(r->right-1,r->top);
  801.         Fore555Dark(x);
  802.         LineTo(r->right-1,r->bottom-1);
  803.         LineTo(r->left,r->bottom-1);
  804.         }
  805.     }
  806.  
  807. void LoweredRect(Rect *r,register short x)
  808. /*
  809.   * Draw rectangle r with a 1 pixel highlight
  810.   * to raise it off the screen
  811.   */
  812.     {
  813.     PenSize(1,1);
  814.     Fore555(x);
  815.     PaintRect(r);
  816.     Fore555Dark(x);
  817.     MoveTo(r->left,r->bottom-1);
  818.     LineTo(r->left,r->top);
  819.     LineTo(r->right-1,r->top);
  820.     Fore555Light(x);
  821.     LineTo(r->right-1,r->bottom-1);
  822.     LineTo(r->left,r->bottom-1);
  823.     }
  824.